package cn.layfolk.seckill.redis;

import lombok.Getter;

import java.util.concurrent.TimeUnit;

@Getter
public enum SeckillRedisKey {

    SECKILL_ORDER_SET("seckillOrderSet:"),
    SECKILL_GOODS_HASH("seckillGoodsHash"),
    SECKILL_STOCK_COUNT_HASH("seckillStockCountHash"),
    SECKILL_VERIFY_CODE_RET("seckill:verifyCode:",3L,TimeUnit.MINUTES),
    SECKILL_PATH_HASH("seckillPath:",30L,TimeUnit.SECONDS)
    ;

    //前缀
    private String prefix;
    //过期时间
    private Long expireTime;
    //过期时间类型
    private TimeUnit unit;


    SeckillRedisKey(String prefix){
        this(prefix,0L,null);
    }

    SeckillRedisKey(String prefix, Long expireTime, TimeUnit unit){
        this.prefix = prefix;
        this.expireTime = expireTime;
        this.unit = unit;
    }


    public String getRealKey(String key) {
        return this.getPrefix() + key;
    }

}
